package com.fosung.frame.modules.approve.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fosung.frame.common.persistence.Page;
import com.fosung.frame.common.service.CrudService;
import com.fosung.frame.modules.approve.dao.StatisticDao;
import com.fosung.frame.modules.approve.entity.PartyStatistic;
import com.fosung.frame.modules.approve.entity.PersonStatistic;
import com.fosung.frame.modules.score.dao.OrganizePersonDetailDao;

/*
 * 统计分析
 */
@Service
@Transactional(readOnly = true)
public class StatisticService extends CrudService<StatisticDao, PartyStatistic> {
	@Autowired
	private OrganizePersonDetailDao organizePersonDetailDao;

	/**
	 * 查询党组织积分排名
	 * 
	 * @param partyStatistic
	 * @return
	 */
	public List<PartyStatistic> findPartyPmList(PartyStatistic partyStatistic) {
		return dao.findPartyPmList(partyStatistic);
	}

	/**
	 * 统计分析 查询党组织排名
	 * 
	 * @param page
	 * @param partyStatistic
	 * @return
	 */
	public Page<PartyStatistic> findPartyPmPage(Page<PartyStatistic> page, PartyStatistic partyStatistic) {
		partyStatistic.setPage(page);
		List<PartyStatistic> list = dao.findPartyPmPage(partyStatistic);
		for (int i = 0; i < list.size(); i++) {
			list.get(i).setNumPm((i + 1) + "");
		}
		page.setList(list);
		return page;
	}

	/**
	 * 首页 查询党员积分排名
	 * 
	 * @param partyScoreRanking
	 * @return
	 */
	public List<PersonStatistic> findPersonPmList(PersonStatistic personStatistic) {
		return dao.findPersonPmList(personStatistic);
	}

	/**
	 * 统计分析 查询党员排名
	 * 
	 * @param page
	 * @param personStatistic
	 * @return
	 */
	public Page<PersonStatistic> findPersonPmPage(Page<PersonStatistic> page, PersonStatistic personStatistic) {
		personStatistic.setPage(page);
		List<PersonStatistic> list = dao.findPersonPmPage(personStatistic);
		for (int i = 0; i < list.size(); i++) {
			list.get(i).setNumPm((i + 1) + "");
		}
		page.setList(list);
		return page;
	}

	/**
	 * 查询社区类型下的所有组织树
	 * 
	 * @param typeId
	 * @return
	 */
	public List<Map<String, String>> findOrganizeNameByTypeId(PartyStatistic partyStatistic) {
		return dao.findOrganizeNameByTypeId(partyStatistic);
	}

	/**
	 * 党支部查询积分统计明细
	 */
	public List<PersonStatistic> findPersonByOrganize(PersonStatistic personStatistic) {
		List<PersonStatistic> list = organizePersonDetailDao.findPersonByOrganize(personStatistic);

		return list;
	}

}
